function goback() {
	history.back();
}
$(function() {
	var geolocation = new BMap.Geolocation();
	geolocation.getCurrentPosition(function(r) {
		var gps_w = r.point.lat;
		var gps_j = r.point.lng;
		console.log(gps_j);
		console.log(gps_w);
		var token = localStorage.phone;
		$.ajax({
			url: "https://newapp.icandrive.cn/api/teacherInfo.php",
			type: 'post',
			data: {
				token: token,
				gps_w: gps_w,
				gps_j: gps_j
			},
			dataType: 'json',
			success: function(data) {
				if(data.status == 200) {
					console.log(data);
					$(data.data).each(function() {
							var distance = Math.ceil(this.distance / 1000);
						$('.main_message_moudule').append(
							'<li class="introduce_coach" i="' + this.teacher_id + '">' +
							'<div class="left_introduce">' +
							'<img src=' + this.teacher_photo + ' >' +
							'<p>车型任选</p>' +
							'</div>' +
							'<input class="T_id" type="hidden" value="' + this.teacher_id + '" />' +
							'<div class="right_introduce">' +
							'<div class="right_introduce_top">' +
							'<h3>' + this.teacher_name + '</h3>' +
							'<p class="subject2">科二:' + this.subject2_place + '/小时</p>' +
							'<p class="subject3">科三:' + this.subject3_place + '/小时</p>' +
							'<p class="subject4"><img src="locate.png" alt="距离" style=" vertical-align: middle;"><span>距'+distance+'km</span></p>'+
							'</div>' +
							'<div class="right_introduce_middle">' +
							'<p>' + this.autograph + '</p>' +
							'</div>' +
							'<div class="right_introduce_down clearfix">' +
							/*'<p>17人已评价</p>'+
									'<p>16人已预约</p>'+*/
							'</div>' +
							'</div>' +
							'</li>'
						);

					})
				}
				if(data.status == 250) {
					layer.msg("请重新登录");
					setInterval(function() {
						window.location.href = "../login/log_in.html";
					}, 2000)
				}
				if(data.status == 400) {
					layer.msg('没找到附近教练');
				}
			},
			error: function() {
				layer.msg('系统繁忙', function() {
					history.go(0)
				}, 1000);
			}
		});
		$('.main_message_moudule').on('click', 'li', function() {
			var id = $(this).attr('i');
			localStorage.teacher_id = id;
			localStorage.teacher_id = id;
			window.location.href = "../date_teacher2/teaching.html";
		})
	})
})
